package Learn_JDom_Dom4J;
import java.io.IOException;
import java.util.List;

import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;


public class LearnJDom {
	public static void main(String [] args){
		SAXBuilder builder = new SAXBuilder();
		try {
			Document document = builder.build("src\\Learn_JDom_Dom4J\\Student.xml");
			Element root =  document.getRootElement();
			
			List<Element> list = root.getChildren();
			for(Element e:list){
				if(!"student".equals(e.getName())){
					continue;
				}
				System.out.println("--------Student---------");
				System.out.println("id: " + e.getAttributeValue("id"));
				System.out.println("name: " + e.getChildText("name"));
				System.out.println("gender: " + e.getChildText("gender"));
				System.out.println("age: " + e.getChildText("age"));
				
					
			}
			
			
		} catch (JDOMException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
}
